package com.tedu._04mybatis.mapper;

import com.tedu._04mybatis.pojo.Weibo;
import com.tedu._04mybatis.pojo.WeiboVO1;
import com.tedu._04mybatis.pojo.WeiboVO2;
import com.tedu._04mybatis.pojo.WeiboVO3;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiboMapper {
    //@Insert("INSERT INTO weibo(content,created,user_id) VALUES (#{content},#{created},#{userId})")
    int insert(Weibo weibo);

    //@Delete("DELETE FROM weibo WHERE id=#{id}")
    int deleteWeiboId(Integer id);

    //@Update("UPDATE weibo SET content=#{content},created=#{created},user_id=#{userId} WHERE id=#{id}")
    int updateWeiboId(Weibo weibo);

    /*
    例如下面的查询
    表中content字段和Weibo类中的content属性名一直，那么可以被直接设置
     */
    //@Select("SELECT id,content,created,user_id userId FROM weibo WHERE id= #{id}")
    Weibo selectWeiboId(Integer id);

    //@Select("SELECT id,content,created,user_id userId FROM weibo")
    List<Weibo> selectWeiboAll();

    //@Select("SELECT content,created FROM weibo WHERE id=#{id}")
    WeiboVO1 selectWeiboVO1Id(Integer id);

    //@Select("SELECT content,created,user_id userId FROM weibo")
    List<WeiboVO2> selectAllWeiboVO2();

    int dynamicUpdateWeibo(Weibo weibo);//动态更新

    int dynamicDeleteWeibo(Integer[] ids);//动态删除（数组）

    int dynamicDeleteWeibo2(List<Integer> ids);//动态删除(集合)

    int countWeibo();

    WeiboVO3 selectWeiboVO3(Integer id);//嵌套查询

    List<WeiboVO3> selectAllWeiboVO3();
}
